Skip to content

Improved devex ergonomics#36

Merged
jwilger merged 2 commits intomainfrom
set-state-signature
Mar 8, 2025
Merged

Improved devex ergonomics#36
jwilger merged 2 commits intomainfrom
set-state-signature

Conversation

@jwilger
Copy link
Copy Markdown
Owner

@jwilger jwilger commented Mar 8, 2025

This pull request refactors the Command trait and its implementations to improve type safety and consistency. The changes include modifying the trait to use an associated type for events, updating method signatures, and adjusting implementations accordingly.

Key changes include:

Trait Refactoring:

  • The Command trait now uses an associated type Event instead of a generic parameter, which simplifies the trait's usage and improves type safety. (src/command.rs, [[1]](https://github.com/jwilger/mneme/pull/36/files#diff-de6b9cfd1a256da7900d35e26aa7279bd713110e68e91b52616befb7397848dfL6-R17), [[2]](https://github.com/jwilger/mneme/pull/36/files#diff-de6b9cfd1a256da7900d35e26aa7279bd713110e68e91b52616befb7397848dfL29-R43))
  • The AggregateState trait's apply method now takes a reference to the event instead of consuming it, which aligns with the new Command trait. (src/command.rs, [src/command.rsL29-R43](https://github.com/jwilger/mneme/pull/36/files#diff-de6b9cfd1a256da7900d35e26aa7279bd713110e68e91b52616befb7397848dfL29-R43))

Method Signature Updates:

  • Updated the handle and apply methods in the Command trait to use the associated Event type. (src/command.rs, [src/command.rsL6-R17](https://github.com/jwilger/mneme/pull/36/files#diff-de6b9cfd1a256da7900d35e26aa7279bd713110e68e91b52616befb7397848dfL6-R17))
  • Changed the set_state method to take a mutable reference to self instead of consuming self. (src/command.rs, [src/command.rsL6-R17](https://github.com/jwilger/mneme/pull/36/files#diff-de6b9cfd1a256da7900d35e26aa7279bd713110e68e91b52616befb7397848dfL6-R17))

Implementation Adjustments:

  • Updated various implementations of the Command trait in the test cases to match the new trait definition. (src/lib.rs, [[1]](https://github.com/jwilger/mneme/pull/36/files#diff-b1a35a68f14e696205874893c07fd24fdb88882b47c23cc0e0c80a30c7d53759L171-R177), [[2]](https://github.com/jwilger/mneme/pull/36/files#diff-b1a35a68f14e696205874893c07fd24fdb88882b47c23cc0e0c80a30c7d53759L329-R338), [[3]](https://github.com/jwilger/mneme/pull/36/files#diff-b1a35a68f14e696205874893c07fd24fdb88882b47c23cc0e0c80a30c7d53759L466-R465), tests/test_cases.rs, [[4]](https://github.com/jwilger/mneme/pull/36/files#diff-4300fcbb75cb722103f54594a5422baf31a5e7753a5ad32e7f9eb2ecdf9b8c83L24-R25), [[5]](https://github.com/jwilger/mneme/pull/36/files#diff-4300fcbb75cb722103f54594a5422baf31a5e7753a5ad32e7f9eb2ecdf9b8c83L55-R55), [[6]](https://github.com/jwilger/mneme/pull/36/files#diff-4300fcbb75cb722103f54594a5422baf31a5e7753a5ad32e7f9eb2ecdf9b8c83L82-R81), [[7]](https://github.com/jwilger/mneme/pull/36/files#diff-4300fcbb75cb722103f54594a5422baf31a5e7753a5ad32e7f9eb2ecdf9b8c83L141-R148))
  • Adjusted the apply method in AggregateState implementations to match the new signature. (src/lib.rs, [[1]](https://github.com/jwilger/mneme/pull/36/files#diff-b1a35a68f14e696205874893c07fd24fdb88882b47c23cc0e0c80a30c7d53759L383-R388), tests/test_cases.rs, [[2]](https://github.com/jwilger/mneme/pull/36/files#diff-4300fcbb75cb722103f54594a5422baf31a5e7753a5ad32e7f9eb2ecdf9b8c83L108-R112))

Function Signature Updates:

  • Updated the execute function to use the new Command trait definition with the associated Event type. (src/lib.rs, [[1]](https://github.com/jwilger/mneme/pull/36/files#diff-b1a35a68f14e696205874893c07fd24fdb88882b47c23cc0e0c80a30c7d53759L23-R23), [[2]](https://github.com/jwilger/mneme/pull/36/files#diff-b1a35a68f14e696205874893c07fd24fdb88882b47c23cc0e0c80a30c7d53759L48-R48))

@jwilger jwilger enabled auto-merge (squash) March 8, 2025 04:39
@jwilger jwilger merged commit e5bf792 into main Mar 8, 2025
2 checks passed
@jwilger jwilger deleted the set-state-signature branch March 8, 2025 04:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant